﻿using UnityEngine;
using System.Runtime.InteropServices;

public class GetFreeDiskSpaceManager
{
#if UNITY_IPHONE || UNITY_EDITOR
    [DllImport("__Internal")]
    private static extern long _GetFreeDiskSpace();
#endif

    public static long GetFreeDiskSpace()
    {
#if UNITY_IPHONE
        return _GetFreeDiskSpace();
#elif UNITY_ANDROID
        AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
        if (jo != null)
        {
            string memoryInfo = jo.Call<string>("getMemoryInfo");
            return long.Parse(memoryInfo);
        }
#endif
        return 0;
    }

}
